/**
 * Copyright 2019 [shujiang.yang], Inc. All rights reserved.
 * Email: 314938230@qq.com
**/
package awd.bj.jls.webs.controller;

import awd.bj.jls.model.LdspModel;
import awd.bj.jls.webs.api.JlsServersApi;
//import awd.bj.jls.webs.api.model.JbxxLdspModel;
import awd.bj.jls.webs.api.model.User;
import awd.bj.jls.webs.utils.*;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/jbxxLdsp")
@RefreshScope
public class JbxxLdspAction extends BaseAction {

    @Autowired
    private JlsServersApi jlsServersApi;

    @RequestMapping({"/jbxxLdsp.html" //首页
            ,"/jbxxLdsp_enter.html" //单表录入页面
            ,"/jbxxLdsp_jbxx_enter.html" //人员信息查询页面
            ,"/jbxxLdsp_query.html" //信息查询
            ,"/jbxxLdsp_jbxx_query.html" //关联基本信息查询
            ,"/6.html" //
            ,"/7.html"})
    public String index(Model model, HttpServletRequest request) {
        model.addAllAttributes(getBaseModelData());
        return getRenderFilePath(request);
    }
    
    //正常入所领导审批
    @RequestMapping("/ldspAdd")
    @ResponseBody
    public Result<?> ldspAdd(@ModelAttribute LdspModel ldspModel,HttpServletRequest request) {
	    User users = this.getCurrentUser();
	    try {
	    String taskid = request.getParameter("taskid");
	    ldspModel.setState("R2");
	    ldspModel.setJsbh(users.getJsbh());
	    ldspModel.setCreator(users.getUsername());
	    ldspModel.setCreatetime(new Date());
	        System.err.println("何磊:保存数据====================================");
	        System.err.println(JSON.toJSONString(ldspModel));
	        System.err.println("================================================================");
	
	   return ResultUtils.success(jlsServersApi.ldspSaveByparam(taskid, ldspModel));
	    } catch (Exception e) {
	    e.printStackTrace();
	    return ResultUtils.error(Result.ERR_SAVE, "保存失败");
	    }
    }

}